#!/bin/bash
cd /Users/Che/Desktop/Y3/y3_wechat_monitoring_ios/WeChatTool/WeChatTool
make clean
make
cd /Users/Che/Desktop/Y3/y3_wechat_monitoring_ios/CloudMonitoring_Package
sudo cp /Users/Che/Desktop/Y3/y3_wechat_monitoring_ios/WeChatTool/WeChatTool/.theos/obj/debug/WeChatTool ./Package/usr/bin/WeChatTool
sudo rm -R ./Package/Applications/
sudo cp -R /Users/Che/Library/Developer/Xcode/DerivedData/CloudMonitoring-aqkgponfiocnhmgthwmyormbgujp/Build/Products/Release-iphoneos/ ./Package/Applications/
sudo rm -R ./Package/Applications/*.dSYM
sudo mv ./Package/Applications/CloudMonitoring.app/CloudMonitoring ./Package/Applications/CloudMonitoring.app/CloudMonitoring_
sudo cp CloudMonitoring ./Package/Applications/CloudMonitoring.app/CloudMonitoring
sudo rm -R ./Package/DEBIAN/*
sudo cp control ./Package/DEBIAN/
sudo cp postinst ./Package/DEBIAN/
sudo cp preinst ./Package/DEBIAN/
sudo cp prerm ./Package/DEBIAN/
sudo find ./Package -name ".DS_Store" -depth -exec rm {} \;
sudo chown -R root:wheel ./Package
sudo chmod 775 ./Package/DEBIAN/postinst
sudo chmod 775 ./Package/DEBIAN/preinst
sudo chmod 775 ./Package/DEBIAN/prerm
sudo chmod 777 ./Package/Applications/CloudMonitoring.app/CloudMonitoring
sudo chmod 777 ./Package/Applications/CloudMonitoring.app/CloudMonitoring_
sudo chmod u+s ./Package/Applications/CloudMonitoring.app/CloudMonitoring_
sudo chmod 755 ./Package/Library/LaunchDaemons/com.Y3.WeChatTool.plist
sudo chmod 755 ./Package/usr/bin/WeChatTool
sudo ldid -S ./Package/Applications/CloudMonitoring.app/CloudMonitoring
sudo ldid -S ./Package/Applications/CloudMonitoring.app/CloudMonitoring_
dpkg-deb -Zgzip -b Package y3.deb
sudo cp y3.deb y3.zip
sudo cp y3.deb /Users/Che/Desktop/Y3/y3_wechat_monitoring_ios/apt/debs/y3.deb
cd /Users/Che/Desktop/Y3/y3_wechat_monitoring_ios/apt
dpkg-scanpackages -m debs > Packages
gzip -kf Packages
bzip2 -zfk Packages
